fdo#47325 legacy reports: survive absence of Sorting hidden control
authorLionel Elie Mamane <lionel@mamane.lu>
Tue, 5 Jun 2012 16:40:13 +0000 (18:40 +0200)
committerRene Engelhard <rene@debian.org>
Wed, 1 Aug 2012 08:41:17 +0000 (08:41 +0000)
Reports created in 3.4 and earlier lack it.

Change-Id: I2cf1cad75fff59f23ad98299c4f94253adf7355b

Gbp-Pq: Name fix-legacy-report-opening.diff

wizards/com/sun/star/wizards/report/ReportTextImplementation.java

index 9e73038e14f677d0a9b3223ad4cc73feaa0ba35a..33f3cf0a403945e8c44c6d4888173f1c82d77edc 100644 (file)
@@ -57,6 +57,7 @@ import com.sun.star.wizards.common.PropertyNames;
 import com.sun.star.wizards.common.SystemDialog;
 import com.sun.star.wizards.db.DBMetaData;
 import com.sun.star.wizards.document.OfficeDocument;
+import com.sun.star.wizards.document.FormHandler.UnknownHiddenControlException;
 import com.sun.star.wizards.ui.UIConsts;
 import java.util.ArrayList;
 import java.util.Vector;
@@ -233,7 +234,15 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
                 String sCommandType = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, PropertyNames.COMMAND_TYPE, sMsg);
                 String sGroupFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "GroupFieldNames", sMsg);
                 String sFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "FieldNames", sMsg);
-                final String sorting = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "Sorting", sMsg);
+                String sorting;
+                try
+                {
+                    sorting = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "Sorting", sMsg);
+                }
+                catch (UnknownHiddenControlException exception)
+                {
+                   sorting = "";
+                }
                 String sRecordFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "RecordFieldNames", sMsg);
                 if (xNamedForm.hasByName("QueryName"))
                 {
@@ -270,7 +279,6 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
                         {
                             getRecordParser().Command = (String) oCommand.getPropertySet().getPropertyValue(PropertyNames.COMMAND);
                             getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command);
-                            getRecordParser().getSQLQueryComposer().prependSortingCriteria();
                             getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery();
                         }
                         else
@@ -283,7 +291,14 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
                     bexecute = getRecordParser().executeCommand(nCommandType); //sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot, sFieldNameList, true);
                     if (bexecute)
                     {
+                        DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName);
                         bexecute = getRecordParser().getFields(sFieldNameList, true);
+                        if (bexecute && getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()))
+                        {
+                            getRecordParser().getSQLQueryComposer().prependSortingCriteria();
+                            getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery();
+                            bexecute = getRecordParser().executeCommand(nCommandType);
+                        }
                     }
                     return bexecute;
                 }